//
//  NSView+Color.swift
//  AutoModel
//
//  Created by 好米有易 on 2019/8/1.
//  Copyright © 2019 own. All rights reserved.
//

import Cocoa

extension NSView {

    /// 设置NSView的背景颜色
    /// 由于NSView和iOS的UIView不同不能直接设置背景颜色所以拓展方法方便创建
    /// - Parameter color: 要设置的颜色
    func set(color: NSColor) {
        let viewLayer = CALayer()
        viewLayer.backgroundColor = color.cgColor
        self.wantsLayer = true
        self.needsDisplay = true
        self.layer = viewLayer;
    }

}
